var deleteDuplicates = function (head) {
  let p = head
  if (p) {
    while (p.next) {
      let next = p.next
      if (p.val === next.val) {
        p.next = next.next
      } else {
        p = next
      }
    }
  }
  return head
}